﻿Imports BUS
Public Class frmxlcapnhatsach

    Private _masach As Integer
    Public Property MaSach() As Integer
        Get
            Return _masach
        End Get
        Set(ByVal value As Integer)
            _masach = value
        End Set
    End Property

    Private Sub btntiepnhan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btntiepnhan.Click
        Dim _ngay As String = String.Format("{0:dd/MM/yyyy}", DateEditngaynhap.EditValue)

        Dim sql As String = "update SACH set TenSach = '" & txttensach.Text & "' , MaTheLoai = " & LookUptheloai.EditValue.ToString() & ", MaTacGia = " & LookUpEdit_TacGia.EditValue.ToString() & ", NamXuatBan = " & SpinEdit_NamXuatBan.Value.ToString() & " "
        sql = sql & " , MaNhaSanXuat = " & LookUpEdit_NhaXuatBan.EditValue.ToString() & ",  NgayNhap = '" & _ngay & "', TriGia = " & SpinEdit_TriGia.Value.ToString() & ", MaNhanVien = " & LookUpnguoitiepnhan.EditValue.ToString() & ", MaTinhTrangSach = " & LookUpEdit_TinhTrangSach.EditValue.ToString()
        sql = sql & " where MaSach = " & _masach.ToString()

        Dim bus As New SachBUS()

        If bus.CapNhatSach(sql) = 1 Then
            MessageBox.Show("Cập nhật sách thành công !")
        Else
            MessageBox.Show("Cập nhật sách thất bại!")
        End If

    End Sub
End Class